#include "stdafx.h"
#include "Picture.h"

Picture::Picture(const std::string& image, const Vector2D<s32>& position) : Picture("game_interface", image, position)
{
}

Picture::Picture(const std::string& group, const std::string& image, const Vector2D<s32>& position) : m_position(position)
{
    m_pImage = LoadResource<SDLTexture>(group, image);

    if (m_pImage)
    {
        Init(m_position, m_pImage->GetDimension());
    }
}

void Picture::SetPicture(const std::string& group, const std::string& image)
{
    m_pImage = LoadResource<SDLTexture>(group, image);

    if (m_pImage)
    {
        Init(GetRelativePosition(), m_pImage->GetDimension());
    }
}

void Picture::Render(SDL_Renderer& renderer)
{
    if (m_pImage)
    {
        Vector2D<s32> size = m_pImage->GetDimension();
        SDL_Rect src = { 0, 0, size.GetX(), size.GetY() };
        SDL_RenderCopyEx(&renderer, m_pImage->GetTexture(), &src, &GetRectangle(), 0, NULL, SDL_FLIP_NONE);
    }
}
